#include <amxmodx>
#include <fun>
#include <rpgx>

new upgrade_id;

public plugin_init()
	register_plugin("IceStab RPGx Upgrade", "2.0", "roflmao456");

public RPGx_OnPluginReady()
	upgrade_id = RPGx_MakeUpgrade("IceStab", 3, 20, 30);

public RPGx_OnPlayerDeath(victim, killer, headshot)
	remove_task(victim);

public RPGx_OnPlayerHurt(victim, attacker, damage, weapon){
	if(get_user_health(victim) > damage){
		new level = RPGx_GetUpgradeLevel(attacker, upgrade_id);
		if(level && weapon == CSW_KNIFE && damage > 25){
			remove_task(victim);
			RPGx_Freeze(victim);
			set_task(float(RPGx_GetUpgradeLevel(attacker, upgrade_id)), "Defrost", victim);
			}
		} else {
		set_user_rendering(victim);
		}
	}

public Defrost(id){
	RPGx_Freeze(id, false);
	remove_task(id);
	}